package com.CmJava.entity;

public class ResultEntity<T> {
    private boolean resultFlag;
    private String message;
    private T data;

    private static final String successMessage="请求成功";
    private static final String failureMessage="请求失败";

    public ResultEntity() {
    }

    public ResultEntity(boolean resultFlag, String message, T data) {
        this.resultFlag = resultFlag;
        this.message = message;
        this.data = data;
    }

    public boolean getResultFlag() {
        return resultFlag;
    }

    public void setResultFlag(boolean resultFlag) {
        this.resultFlag = resultFlag;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static String getSuccessMessage() {
        return successMessage;
    }

    public static String getFailureMessage() {
        return failureMessage;
    }

    public static ResultEntity successWithoutMessage(){
        return new ResultEntity(true,successMessage,null);
    }
    public static <T> ResultEntity successWithMessage(T data){
        return new ResultEntity(true,successMessage,data);
    }
    public static ResultEntity failureWithoutMessage(){
        return new ResultEntity(false,failureMessage,null);
    }
    public static <T> ResultEntity failureWithMessage(T data){
        return new ResultEntity(false,failureMessage,data);
    }

    @Override
    public String toString() {
        return "ResultEntity{" +
                "resultFlag=" + resultFlag +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
